//package com.huonan.jb.treads.autodown;
//
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.scheduling.annotation.EnableAsync;
//import org.springframework.scheduling.annotation.EnableScheduling;
//import org.springframework.scheduling.annotation.SchedulingConfigurer;
//import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
//import org.springframework.scheduling.config.ScheduledTaskRegistrar;
//
//import java.util.concurrent.Executor;
//
//@Configuration
//@EnableAsync
//@EnableScheduling
//public class ThreadPoolConfig implements SchedulingConfigurer {
//
//    @Autowired
//    private ThreadPoolProperties threadPoolProperties;
//
//    @Bean
//    public Executor taskExecutor() {
//        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
//        executor.setCorePoolSize(threadPoolProperties.getCorePoolSize());
//        executor.setMaxPoolSize(threadPoolProperties.getMaxPoolSize());
//        executor.setQueueCapacity(threadPoolProperties.getQueueCapacity());
//        executor.setThreadNamePrefix(threadPoolProperties.getThreadNamePrefix());
//        executor.initialize();
//        return executor;
//    }
//
//    @Override
//    public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
//        taskRegistrar.setScheduler(taskExecutor());
//    }
//}